package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CoffeeShopInfo;
import com.ruoyi.system.service.ICoffeeShopInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地区店铺信息Controller
 * 
 * @author Lin
 * @date 2024-02-11
 */
@RestController
@RequestMapping("/system/shopinfo")
public class CoffeeShopInfoController extends BaseController
{
    @Autowired
    private ICoffeeShopInfoService coffeeShopInfoService;

    /**
     * 查询地区店铺信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:shopinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CoffeeShopInfo coffeeShopInfo)
    {
        startPage();
        List<CoffeeShopInfo> list = coffeeShopInfoService.selectCoffeeShopInfoList(coffeeShopInfo);
        return getDataTable(list);
    }

    /**
     * 导出地区店铺信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:shopinfo:export')")
    @Log(title = "地区店铺信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CoffeeShopInfo coffeeShopInfo)
    {
        List<CoffeeShopInfo> list = coffeeShopInfoService.selectCoffeeShopInfoList(coffeeShopInfo);
        ExcelUtil<CoffeeShopInfo> util = new ExcelUtil<CoffeeShopInfo>(CoffeeShopInfo.class);
        util.exportExcel(response, list, "地区店铺信息数据");
    }

    /**
     * 获取地区店铺信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shopinfo:query')")
    @GetMapping(value = "/{shopId}")
    public AjaxResult getInfo(@PathVariable("shopId") Long shopId)
    {
        return success(coffeeShopInfoService.selectCoffeeShopInfoByShopId(shopId));
    }

    /**
     * 新增地区店铺信息
     */
    @PreAuthorize("@ss.hasPermi('system:shopinfo:add')")
    @Log(title = "地区店铺信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CoffeeShopInfo coffeeShopInfo)
    {
        return toAjax(coffeeShopInfoService.insertCoffeeShopInfo(coffeeShopInfo));
    }

    /**
     * 修改地区店铺信息
     */
    @PreAuthorize("@ss.hasPermi('system:shopinfo:edit')")
    @Log(title = "地区店铺信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CoffeeShopInfo coffeeShopInfo)
    {
        return toAjax(coffeeShopInfoService.updateCoffeeShopInfo(coffeeShopInfo));
    }

    /**
     * 删除地区店铺信息
     */
    @PreAuthorize("@ss.hasPermi('system:shopinfo:remove')")
    @Log(title = "地区店铺信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopIds}")
    public AjaxResult remove(@PathVariable Long[] shopIds)
    {
        return toAjax(coffeeShopInfoService.deleteCoffeeShopInfoByShopIds(shopIds));
    }
}
